import './index.less';
import Left from '@/layout/left/Left';
import Top from '@/layout/top/Top';
import { useEffect } from 'react';
import { useDispatch, useSelector } from 'umi';
import { IndexModelState } from '@/models/index';
import Hoc from "@/hoc"
interface Iprops  {
  index: IndexModelState;
  children:any;
  listRouter:any
}
function IndexPage(props: Iprops) {
  const dispatch = useDispatch();
  //请求用户信息
  useEffect(() => {
    dispatch({ type: 'index/GET_INFO' });
  }, []);
  //获取仓库中的用户信息
  const { userInfo } = useSelector<Iprops, IndexModelState>(
    (state) => state.index,
  );
  
  return (
    <div className="app">
      <Top
        user_name={userInfo.user_name}
        identity_text={userInfo.identity_text}
      />
      <div className="con">
        <Left authorConfig={props.listRouter}/>
        <div className="right">{props.children}</div>
      </div>
    </div>
  );
}
export default Hoc()(IndexPage)